package com.jiwei.system.serviceImpl;

import com.jiwei.system.dao.MemberLoginMapper;
import com.jiwei.system.pojo.MemberLogin;
import com.jiwei.system.pojo.ResultPoJo;
import com.jiwei.system.service.LoginService;
import com.jiwei.system.utils.SMSUtil;
import com.jiwei.system.vo.Login;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @title: PasswordLoginServiceImpl
 * @Author 赖志宇
 * @Description TODO
 * @Date: 2020/8/17
 * @Version 1.0
 */
@Service("Pwd")
public class PwdLoginService implements LoginService<MemberLogin> {

    @Resource
    private MemberLoginMapper memberLoginMapper;

    public PwdLoginService(){
        userLoginMethodMap.put("pwd",this);
    }

    @Override
    public ResultPoJo verifyLogin(MemberLogin memberLogin) {
        MemberLogin login = memberLoginMapper.queryMemberLoginByAccount(memberLogin.getAccount());

        return memberLogin.equals(login)?new ResultPoJo("200"):new ResultPoJo("400");
    }


    @Override
    public ResultPoJo beforeLogin(MemberLogin memberLogin) {
        return null;
    }

    @Override
    public ResultPoJo loginFail(MemberLogin memberLogin) {
        return new ResultPoJo("400", "登陆失败", null);
    }

    @Override
    public ResultPoJo loginSuccess(MemberLogin memberLogin) {
        MemberLogin login = memberLoginMapper.queryMemberLoginByAccount(memberLogin.getAccount());
        return new ResultPoJo("200","登录成功",login);
    }
}
